import { DeleteOrder } from "@/apis/consult"
import { OrderType } from "@/enums"
import type { ConsultOrderItem } from "@/types/consult"
import { showToast } from "vant"
import { ref } from "vue"

export const usseDeleteOrder = (callback:()=>void)=>{
  const deleteLoding = ref(false)
const deleteOrder = async (item: ConsultOrderItem) => {
  try {
    deleteLoding.value = true
    await DeleteOrder(item.id)
    item.status = OrderType.ConsultCancel
    showToast('删除成功')
    // emit('on-delete', item.id)组件里面才能用
    callback && callback()
  } catch (error) {
    showToast('删除失败')
  }
  finally {
    deleteLoding.value = false
  }
}
return{
  deleteLoding,
  deleteOrder
}
}